package com.atguigu.seckill.controller;

import com.atguigu.common.utils.R;
import com.atguigu.seckill.service.SecKillSevice;
import com.atguigu.seckill.vo.SecKillSkuReids;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("seckill")
public class SecKillController {

    @Autowired
    SecKillSevice secKillSevice;

    //查询正在参与秒杀的商品
    @GetMapping("/listSecKillInfo")
    public R listSecKillProducts() {
        List<SecKillSkuReids> killSkuReidsList = secKillSevice.listSecKillProducts();
        return R.ok().setData(killSkuReidsList);
    }


    //查询商品的秒杀信息
    @PostMapping("/skuInfo/{skuId}")
    public R querySkuSeckillInfo(@PathVariable("skuId") String skuId) {
        SecKillSkuReids secKillSkuReids = secKillSevice.querySkuSeckillInfo(skuId);
        return R.ok().setData(secKillSkuReids);
    }

    //秒杀商品http://seckill.gulimall.com/kill?killId=1-48&key=ff2405a2fbc44a01978db8d91e1e7499&num=1
    @GetMapping("/kill")
    public R secKill(@RequestParam("killId") String killId, @RequestParam("key") String key, @RequestParam("num") Integer num) {
        return R.ok();
    }

}
